﻿using System;
using TFSRequestManager.TfsAdministration;

namespace TFSRequestManager
{
    public class ActiveRequest
    {
        #region Constants

        private const string DISPLAY_FORMAT =
            "Request Id: {0}, " +
            "Method Name: {1}, " +
            "User Name: {2}, " +
            "Start Time: {3}, " +
            "Execution Time: {4}, " +
            "Queued Time: {5}, " +
            "Queued: {6}, " +
            "Remote Computer: {7}, " +
            "Remote Port: {8}, " +
            "HostId: {9}, " +
            "Server Activity Name: {10}, " +
            "Server Activity Start Time: {11}, " +
            "Server Activity Status: {12}, " +
            "Server Activity Status Reason: {13}, " +
            "Remote Address: {14}";

        #endregion

        #region Properties

        public long RequestId { get; set; }
        public string MethodName { get; set; }
        public string UserName { get; set; }
        public DateTime StartTime { get; set; }
        public long ExecutionTime { get; set; }
        public long QueuedTime { get; set; }
        public bool Queued { get; set; }
        public string RemoteComputer { get; set; }
        public string RemotePort { get; set; }
        public Guid HostId { get; set; }
        public string ServerActivityName { get; set; }
        public DateTime ServerActivityStartTime { get; set; }
        public int ServerActivityStatus { get; set; }
        public string ServerActivityStatusReason { get; set; }
        public TeamFoundationRequestInformation RequestInformation { get; set; }
        public string RemoteAddress { get; set; }

        #endregion

        #region Public Methods

        public override string ToString()
        {
            return string.Format(
                DISPLAY_FORMAT,
                RequestId,
                MethodName,
                UserName,
                StartTime.ToLocalTime(),
                ExecutionTime,
                QueuedTime,
                Queued,
                RemoteComputer,
                RemotePort,
                HostId,
                ServerActivityName,
                ServerActivityStartTime.ToLocalTime(),
                ServerActivityStatus,
                ServerActivityStatusReason,
                RemoteAddress);
        }

        #endregion
    }
}
